<template>
  <div>
    <dialog-form
      v-model="dialogVisible"
      title="添加标签"
      :cancel-button="true"
      :confirm-button="true"
      :confirm-loading="confirmLoading"
      @confirm="confirmHandler"
    >
      <template #content>
        <label-base-form ref="baseForm" v-model="data"/>
      </template>
    </dialog-form>
  </div>
</template>

<script>
import DialogForm from '@/components/dialog/DialogForm'
import { ref } from 'vue'
import { labelPost } from '@/api/label'
import LabelBaseForm from '@/views/administrator/label/form/base/label-base-form'
export default {
  name: 'label-insert-form',
  components: { LabelBaseForm, DialogForm },
  setup () {
    return {
      dialogVisible: ref(false),
      confirmLoading: ref(false),
      data: ref({})
    }
  },
  methods: {
    confirmHandler () {
      this.confirmLoading = true
      if (!this.data) {
        this.confirmLoading = false
        this.dialogVisible = false
        return
      }
      labelPost(this.data).then(value => {
        this.confirmLoading = false
        this.dialogVisible = false
      })
    }
  }
}
</script>

<style scoped>

</style>
